//
//  RYWuLiuViewController.swift
//  SheYangBigData
//
//  Created by 宋海胜 on 2021/1/14.
//  Copyright © 2021 叁拾叁. All rights reserved.
//



import UIKit

class RYWuLiuViewController: SYBaseViewController , UITableViewDelegate, UITableViewDataSource{
    
    
    
    var tableView: UITableView!
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        setTableView()
        self.title = "物流详情"
        self.view.backgroundColor = Constant.bgViewColor
    }
    

    func setTableView() {
        
        //创建表格视图
        self.tableView = UITableView(frame: CGRect(x: 15.autoWidth(), y: NAV_HEIGHT, width: SCREEN_WIDTH-30.autoWidth(), height: SCREEN_HEIGHT-NAV_HEIGHT-BOTTOM_SAFE_HEIGHT), style:.grouped)
        self.tableView.separatorStyle = .none
        self.tableView.delegate = self
        self.tableView.dataSource = self
        self.tableView.backgroundColor = .clear
        self.tableView!.register(RYYuanhuBottomCell.self, forCellReuseIdentifier: "RYYuanhuBottomCell")
        self.tableView!.register(RYYuanhuTopCell.self, forCellReuseIdentifier: "RYYuanhuTopCell")
        self.tableView!.register(RYWuliuCell.self, forCellReuseIdentifier: "RYWuliuCell")
        self.tableView!.register(RYWuliuFahuoCell.self, forCellReuseIdentifier: "RYWuliuFahuoCell")
        self.tableView!.register(RYWuliuZhuangcheCell.self, forCellReuseIdentifier: "RYWuliuZhuangcheCell")
        
        self.view.addSubview(self.tableView!)
    }
    
    func tableView(_ tableView: UITableView, numberOfRowsInSection section: Int) -> Int {
        return 9
    }
    
    func tableView(_ tableView: UITableView, cellForRowAt indexPath: IndexPath) -> UITableViewCell {
        
        if indexPath.row == 0 {
            
            let cell: RYYuanhuTopCell? = tableView.dequeueReusableCell(withIdentifier: "RYYuanhuTopCell") as? RYYuanhuTopCell
            cell?.selectionStyle = .none
            return cell!
        } else if indexPath.row == 1 {
            let cell: RYWuliuCell? = tableView.dequeueReusableCell(withIdentifier: "RYWuliuCell") as? RYWuliuCell
            cell?.selectionStyle = .none
            return cell!
        } else if indexPath.row == 2 {
            let cell: RYWuliuFahuoCell? = tableView.dequeueReusableCell(withIdentifier: "RYWuliuFahuoCell") as? RYWuliuFahuoCell
            cell?.selectionStyle = .none
            return cell!
        } else if indexPath.row == 3 {
            let cell: RYWuliuFahuoCell? = tableView.dequeueReusableCell(withIdentifier: "RYWuliuFahuoCell") as? RYWuliuFahuoCell
            cell?.selectionStyle = .none
            return cell!
        } else if indexPath.row == 4 {
            let cell: RYWuliuZhuangcheCell? = tableView.dequeueReusableCell(withIdentifier: "RYWuliuZhuangcheCell") as? RYWuliuZhuangcheCell
            cell?.selectionStyle = .none
            return cell!
        } else if indexPath.row == 5 {
            let cell: RYWuliuZhuangcheCell? = tableView.dequeueReusableCell(withIdentifier: "RYWuliuZhuangcheCell") as? RYWuliuZhuangcheCell
            cell?.selectionStyle = .none
            return cell!
        } else if indexPath.row == 6 {
            let cell: RYWuliuFahuoCell? = tableView.dequeueReusableCell(withIdentifier: "RYWuliuFahuoCell") as? RYWuliuFahuoCell
            cell?.selectionStyle = .none
            return cell!
        } else if indexPath.row == 7 {
            let cell: RYWuliuFahuoCell? = tableView.dequeueReusableCell(withIdentifier: "RYWuliuFahuoCell") as? RYWuliuFahuoCell
            cell?.selectionStyle = .none
            return cell!
        } else {
            let cell: RYYuanhuBottomCell? = tableView.dequeueReusableCell(withIdentifier: "RYYuanhuBottomCell") as? RYYuanhuBottomCell
            cell?.selectionStyle = .none
            return cell!
        }
            
    
        
    }
    
    func tableView(_ tableView: UITableView, didSelectRowAt indexPath: IndexPath) {
        print("didSelectRowAt")
    }
    
    func tableView(_ tableView: UITableView, viewForHeaderInSection section: Int) -> UIView? {
        
        let v = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 85.autoWidth()))
        v.backgroundColor = Constant.bgViewColor
        let bg = UIView(frame: CGRect(x: 0, y: 10.autoWidth(), width: SCREEN_WIDTH-30.autoWidth(), height: 75.autoWidth()))
        bg.layer.cornerRadius = 5
        bg.backgroundColor = .white
        let gongsi = UILabel(frame: CGRect(x: 10.autoWidth(), y: 15.autoWidth(), width: 65.autoWidth(), height: 15.autoWidth()))
        gongsi.text = "物流公司"
        gongsi.textColor = UIColor(hex: 0x999999)
        gongsi.font = 14.autoFontSize()
        let bianhao = UILabel(frame: CGRect(x: 10.autoWidth(), y: 45.autoWidth(), width: 65.autoWidth(), height: 15.autoWidth()))
        bianhao.text = "运单编号"
        bianhao.textColor = UIColor(hex: 0x999999)
        bianhao.font = 14.autoFontSize()
        
        let gongsiDetail = UILabel(frame: CGRect(x: 85.autoWidth(), y: 15.autoWidth(), width: SCREEN_WIDTH - 85.autoWidth(), height: 15.autoWidth()))
        gongsiDetail.text = "物流公司"
        gongsiDetail.textColor = UIColor(hex: 0x333333)
        gongsiDetail.font = 14.autoFontSize()
        let bianhaoDetail = UILabel(frame: CGRect(x: 85.autoWidth(), y: 45.autoWidth(), width: SCREEN_WIDTH - 85.autoWidth(), height: 15.autoWidth()))
        bianhaoDetail.text = "运单编号"
        bianhaoDetail.textColor = UIColor(hex: 0x333333)
        bianhaoDetail.font = 14.autoFontSize()
        v.addSubview(bg)
        bg.addSubview(gongsi)
        bg.addSubview(bianhao)
        bg.addSubview(gongsiDetail)
        bg.addSubview(bianhaoDetail)
        return v
    }
    
    func tableView(_ tableView: UITableView, heightForHeaderInSection section: Int) -> CGFloat {
        return 85.autoWidth()
    }
    func tableView(_ tableView: UITableView, viewForFooterInSection section: Int) -> UIView? {
        let v = UIView(frame: CGRect(x: 0, y: 0, width: SCREEN_WIDTH, height: 10.autoWidth()))
        v.backgroundColor = Constant.bgViewColor
        return v
    }
    func tableView(_ tableView: UITableView, heightForFooterInSection section: Int) -> CGFloat {
        return 10.autoWidth()
    }
}
